/*
 * CompraDAO.java
 *
 * Created on 18 de Junho de 2007, 09:21
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package model.persistence.dao;

import com.sun.crypto.provider.RSACipher;
import java.beans.Statement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import model.persistence.vo.Usuario;

/**
 *
 * @author Gustavo
 */
public class CompraDAO extends ConnectionDAO{
    
    /** Creates a new instance of CompraDAO */
    public CompraDAO() {
        super();
    }
    
    public Usuario isRegistered(String login, String senha){
        Usuario usuario = null;
        
        String sql = "select * from usuario u where u.login = '" + login + "' and u.senha = '" + senha + "'";
        
        ResultSet rs = this.executaSelectQuery(sql);
        try {
            if(rs.first()) {
                usuario = new Usuario();
                usuario.setId_usuario(rs.getInt("id_usuario"));
                usuario.setNome(rs.getString("nome"));
                usuario.setLogin(rs.getString("login"));
                usuario.setSenha(rs.getString("senha"));
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
        
        return usuario;
    }
    
    public boolean efetuaCompra(int idCompra, int idUsuario, int idSessao, int nMeias, int nInteiras){
        boolean result = true;
        
        String sql = "insert into compra values (" + idCompra + "," + idUsuario + "," + idSessao + "," + nMeias + "," + nInteiras + ")";
        
       //inserir no banco e retornar true SE conseguir. 
        
        return result;
    }
    
}
